package com.atguigu.mytest.common.utils;

import java.util.HashMap;


public class R extends HashMap<String, Object> {

    public R () {
        this.put("code", 0);
        this.put("msg", "success");
    }

   public R put(String key, Object value) {
        super.put(key, value);
        return this;
   }



    public static R ok () {
        return new R();
    }

    public static R ok (String msg) {
        R r = new R();
        r.put("msg", msg);
        return r;
    }

    public static R ok (HashMap<String, Object> map) {
        R r = new R();
        r.putAll(map);
        return r;
    }

    public Integer getCode() {
        Object codeObj = this.get("code");
        if (codeObj instanceof Integer) {
            return (Integer) codeObj;
        } else {
            return null; // 或者抛出异常，根据具体需求处理
        }
    }
}
